flattenlistmodel: Fix uninitialized variable warning
authorYi-Soo An <yisooan@gmail.com>
Thu, 20 Sep 2018 03:45:33 +0000 (12:45 +0900)
committerYi-Soo An <yisooan@gmail.com>
Thu, 20 Sep 2018 03:45:33 +0000 (12:45 +0900)
Variable, added, would be a garbage value if model is NULL and
the following code, if condition, use the uninitialized variable.
A side effect could be occurred by that.

To avoid, the variable is initialized to zero.

gtk/gtkflattenlistmodel.c

index 3f5e83711e505d65eed707dd12b3491657896f07..b7066742b76e2a45c35c4ff4b596a195bae95fa0 100644 (file)
@@ -480,7 +480,7 @@ void
 gtk_flatten_list_model_set_model (GtkFlattenListModel *self,
                                   GListModel          *model)
 {
-  guint removed, added;
+  guint removed, added = 0;
 
   g_return_if_fail (GTK_IS_FLATTEN_LIST_MODEL (self));
   g_return_if_fail (model == NULL || G_IS_LIST_MODEL (model));